package chances.mock.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

import chances.epg.config.BaseMvcConfig;
import chances.epg.navigator.EpgExceptionHandleResolver;

@Configuration
@PropertySource("/WEB-INF/conf/wechat.properties")
@ComponentScan(basePackages = "chances.mock.controller")
public class GatewayConfig extends BaseMvcConfig {

	@Bean
	EpgExceptionHandleResolver exceptionResolver() {
		return new EpgExceptionHandleResolver();
	}

	@Override
	public RequestMappingHandlerMapping requestMappingHandlerMapping() {
		return super.requestMappingHandlerMapping();
	}

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		//registry.addInterceptor(new WeChatSessionInterceptor()).addPathPatterns("/**");
		/*registry.addInterceptor(accessLogInterceptor());
		registry.addInterceptor(subjectFirstPageInterceptor()).addPathPatterns("/**");
		registry.addInterceptor(navigateHistoryInteceptor());*/
	}

	/*@Bean
	public TokenFactory tokenFactory() {
		TokenFactory factory = new TokenFactory(this.appId, this.secret, this.enableJsApi);
		factory.setTokenResovler(tokenWeixinResovler());
		factory.init();
		return factory;
	}

	@Bean
	public WechatLogger weixinLogger() {
		WechatLoggerImpl loggerImpl = new WechatLoggerImpl();
		loggerImpl.setAppId(appId);
		return loggerImpl;
	}
	
	@Bean
	public WechatTokenService tokenService() {
		RdbWechatTokenService tokenService = new RdbWechatTokenService();
		return tokenService;
	}

	public TokenResovler tokenWeixinResovler() {
		TokenWeixinResovlerImpl resovlerImpl = new TokenWeixinResovlerImpl();
		resovlerImpl.setWxLogger(weixinLogger());
		return resovlerImpl;
	}

	public String getBackPath() {
		return backPath;
	}

	public void setBackPath(String backPath) {
		this.backPath = backPath;
	}

	public String getWgHost() {
		return wgHost;
	}

	public void setWgHost(String wgHost) {
		this.wgHost = wgHost;
	}

	public String getIndexUrl() {
		return indexUrl;
	}

	public void setIndexUrl(String indexUrl) {
		this.indexUrl = indexUrl;
	}

	public String getErrorPage() {
		return this.errorPage;
	}*/
	
}
